//
//  SheetTipsView.swift
//  ShouChong
//
//  Created by yw on 2024/8/12.
//

import UIKit

class SheetTipsView: UIView {

    @IBOutlet weak var titleLabel: UILabel!
    
    @IBOutlet weak var contentLabel: UILabel!
    
    @IBOutlet weak var confirmBtn: UIButton!
    
    @IBOutlet weak var backgroundView: UIView!
    
    var confirmAction:(() -> Void)?
    
    override func awakeFromNib() {
        super.awakeFromNib()
        
        self.backgroundView.layer.cornerRadius = 20
        self.confirmBtn.layer.cornerRadius = 28
        self.confirmBtn.backgroundColor = UIColor(named: GetMainColorTool.getMainColor())
        
    }

    
    @IBAction func confirmBtnClick(_ sender: Any) {
        self.hideToView()
        let generator = UIImpactFeedbackGenerator(style: .light)
        generator.prepare()
        generator.impactOccurred()
        self.confirmAction?()
        
    }
    
    
    class func createSheetTipsView(width:CGFloat = kScreenWidth, height:CGFloat = 330, title:String = "提示",content:String = "",confirmTitle:String = "知道了",confirmAction:@escaping (() -> Void)) -> SheetTipsView {
        let tipsView = Bundle.main.loadNibNamed("SheetTipsView", owner: nil)?.last as! SheetTipsView
        tipsView.frame = CGRect(x: 0, y: 0, width:width , height: height)
        tipsView.confirmAction = confirmAction
        tipsView.confirmBtn.setTitle(confirmTitle, for: .normal)
        tipsView.titleLabel.text = title
        tipsView.contentLabel.text = content
        return tipsView
    }
    
}
